<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registration</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Bonobo Activation API Reference Manual">
<link rel="up" href="api-reference.html" title="API Reference">
<link rel="prev" href="bonobo-activation-Utilities.html" title="Utilities">
<link rel="next" href="bonobo-activation-Debugging.html" title="Debugging">
<meta name="generator" content="GTK-Doc V1.15.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="bonobo-activation-Utilities.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="api-reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Bonobo Activation API Reference Manual</th>
<td><a accesskey="n" href="bonobo-activation-Debugging.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#bonobo-activation-Registration.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#bonobo-activation-Registration.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="bonobo-activation-Registration"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="bonobo-activation-Registration.top_of_page"></a>Registration</span></h2>
<p>Registration — Registering CORBA objects to Bonobo Activation.</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="bonobo-activation-Registration.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;bonobo-activation/bonobo-activation.h&gt;

enum                <a class="link" href="bonobo-activation-Registration.html#Bonobo-RegistrationResult" title="enum Bonobo_RegistrationResult">Bonobo_RegistrationResult</a>;
<span class="returnvalue">void</span>                <a class="link" href="bonobo-activation-Registration.html#bonobo-activation-unregister-active-server" title="bonobo_activation_unregister_active_server ()">bonobo_activation_unregister_active_server</a>
                                                        (<em class="parameter"><code>const <span class="type">char</span> *iid</code></em>,
                                                         <em class="parameter"><code><span class="type">CORBA_Object</span> obj</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="bonobo-activation-Registration.html#bonobo-activation-registration-env-free" title="bonobo_activation_registration_env_free ()">bonobo_activation_registration_env_free</a>
                                                        (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> *reg_env</code></em>);
<a href="http://library.gnome.org/devel/glib/unstable/glib-Singly-Linked-Lists.html#GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="bonobo-activation-Registration.html#bonobo-activation-registration-env-set" title="bonobo_activation_registration_env_set ()">bonobo_activation_registration_env_set</a>
                                                        (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> *reg_env</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *name</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *value</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="bonobo-activation-Registration.html#bonobo-activation-registration-env-set-global" title="bonobo_activation_registration_env_set_global ()">bonobo_activation_registration_env_set_global</a>
                                                        (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> *reg_env</code></em>,
                                                         <em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> append_if_existing</code></em>);
<a class="link" href="bonobo-activation-Registration.html#Bonobo-RegistrationResult" title="enum Bonobo_RegistrationResult"><span class="returnvalue">Bonobo_RegistrationResult</span></a>  <a class="link" href="bonobo-activation-Registration.html#bonobo-activation-register-active-server" title="bonobo_activation_register_active_server ()">bonobo_activation_register_active_server</a>
                                                        (<em class="parameter"><code>const <span class="type">char</span> *iid</code></em>,
                                                         <em class="parameter"><code><span class="type">CORBA_Object</span> obj</code></em>,
                                                         <em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> *reg_env</code></em>);
const <span class="returnvalue">char</span> *        <a class="link" href="bonobo-activation-Registration.html#bonobo-activation-iid-get" title="bonobo_activation_iid_get ()">bonobo_activation_iid_get</a>           (<em class="parameter"><code><span class="type">void</span></code></em>);
                    <a class="link" href="bonobo-activation-Registration.html#BonoboActivationPlugin" title="BonoboActivationPlugin">BonoboActivationPlugin</a>;
                    <a class="link" href="bonobo-activation-Registration.html#BonoboActivationPluginObject" title="BonoboActivationPluginObject">BonoboActivationPluginObject</a>;
<span class="returnvalue">void</span>                <a class="link" href="bonobo-activation-Registration.html#bonobo-activation-plugin-use" title="bonobo_activation_plugin_use ()">bonobo_activation_plugin_use</a>        (<em class="parameter"><code><span class="type">PortableServer_Servant</span> servant</code></em>,
                                                         <em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> impl_ptr</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="bonobo-activation-Registration.html#bonobo-activation-plugin-unuse" title="bonobo_activation_plugin_unuse ()">bonobo_activation_plugin_unuse</a>      (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> impl_ptr</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="bonobo-activation-Registration.description"></a><h2>Description</h2>
<p>
When writing a component which can be activated through
Bonobo Activation by clients, you need to be register your component
to Bonobo Activation once it is created.
</p>
</div>
<div class="refsect1">
<a name="bonobo-activation-Registration.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="Bonobo-RegistrationResult"></a><h3>enum Bonobo_RegistrationResult</h3>
<pre class="programlisting">typedef enum {
  Bonobo_ACTIVATION_REG_SUCCESS,
  Bonobo_ACTIVATION_REG_NOT_LISTED,
  Bonobo_ACTIVATION_REG_ALREADY_ACTIVE,
  Bonobo_ACTIVATION_REG_ERROR
} Bonobo_RegistrationResult;
</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2">
<a name="bonobo-activation-unregister-active-server"></a><h3>bonobo_activation_unregister_active_server ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                bonobo_activation_unregister_active_server
                                                        (<em class="parameter"><code>const <span class="type">char</span> *iid</code></em>,
                                                         <em class="parameter"><code><span class="type">CORBA_Object</span> obj</code></em>);</pre>
<p>
Unregisters <em class="parameter"><code>obj</code></em> with <em class="parameter"><code>iid</code></em> with the local bonobo-activation-server
daemon.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>iid</code></em> :</span></p></td>
<td>IID of the server to unregister.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>obj</code></em> :</span></p></td>
<td>CORBA::Object to unregister.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="bonobo-activation-registration-env-free"></a><h3>bonobo_activation_registration_env_free ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                bonobo_activation_registration_env_free
                                                        (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> *reg_env</code></em>);</pre>
<p>
Frees the registration environment list, <em class="parameter"><code>reg_env</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>reg_env</code></em> :</span></p></td>
<td>a GSList pointer.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="bonobo-activation-registration-env-set"></a><h3>bonobo_activation_registration_env_set ()</h3>
<pre class="programlisting"><a href="http://library.gnome.org/devel/glib/unstable/glib-Singly-Linked-Lists.html#GSList"><span class="returnvalue">GSList</span></a> *            bonobo_activation_registration_env_set
                                                        (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> *reg_env</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *name</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *value</code></em>);</pre>
<p>
Sets the environment variable <em class="parameter"><code>name</code></em> to <em class="parameter"><code>value</code></em> in the
registration environment list <em class="parameter"><code>reg_env</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reg_env</code></em> :</span></p></td>
<td>a GSList pointer.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>name</code></em> :</span></p></td>
<td>the name of the env variable (must not be <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>).
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
<td>the value of the env variable (may be <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>).
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the new start of <em class="parameter"><code>reg_env</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="bonobo-activation-registration-env-set-global"></a><h3>bonobo_activation_registration_env_set_global ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                bonobo_activation_registration_env_set_global
                                                        (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> *reg_env</code></em>,
                                                         <em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> append_if_existing</code></em>);</pre>
<p>
Sets the global registration environment list with the
contents of <em class="parameter"><code>reg_env</code></em>. If <em class="parameter"><code>append_if_existing</code></em> is set to
<a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>, the an existing global list will be overwritten.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>reg_env</code></em> :</span></p></td>
<td>a GSList pointer.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>append_if_existing</code></em> :</span></p></td>
<td>whether or not to append to the global list.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="bonobo-activation-register-active-server"></a><h3>bonobo_activation_register_active_server ()</h3>
<pre class="programlisting"><a class="link" href="bonobo-activation-Registration.html#Bonobo-RegistrationResult" title="enum Bonobo_RegistrationResult"><span class="returnvalue">Bonobo_RegistrationResult</span></a>  bonobo_activation_register_active_server
                                                        (<em class="parameter"><code>const <span class="type">char</span> *iid</code></em>,
                                                         <em class="parameter"><code><span class="type">CORBA_Object</span> obj</code></em>,
                                                         <em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> *reg_env</code></em>);</pre>
<p>
Registers <em class="parameter"><code>obj</code></em> with <em class="parameter"><code>iid</code></em> with the local bonobo-activation-server
daemon.
</p>
<p>
If <em class="parameter"><code>reg_env</code></em> is not <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, <em class="parameter"><code>obj</code></em> will be registered in such a
way that if a client who's environment differs from the
environment specified in <em class="parameter"><code>reg_env</code></em>, then another attempt
to activate <em class="parameter"><code>iid</code></em> will not result in a reference to <em class="parameter"><code>obj</code></em>
being returned, but rather another instance of <em class="parameter"><code>iid</code></em> being
activated.
</p>
<p>
So, for example, you can ensure that a seperate instance
of the component is activated for each distinct X display
(and screen) by:
</p>
<p>
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="normal">display_name </span><span class="symbol">=</span><span class="normal"> </span><span class="function">gdk_display_get_name</span><span class="normal"> </span><span class="symbol">(</span><span class="function">gdk_display_get_default</span><span class="symbol">());</span>
<span class="normal">reg_env </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="bonobo-activation-Registration.html#bonobo-activation-registration-env-set">bonobo_activation_registration_env_set</a></span><span class="normal"> </span><span class="symbol">(</span>
<span class="normal">                           reg_env</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"DISPLAY"</span><span class="symbol">,</span><span class="normal"> display_name</span><span class="symbol">);</span>
<span class="function"><a href="bonobo-activation-Registration.html#bonobo-activation-register-active-server">bonobo_activation_register_active_server</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">iid</span><span class="symbol">,</span><span class="normal"> active_server</span><span class="symbol">,</span><span class="normal"> reg_env</span><span class="symbol">);</span>
<span class="function"><a href="bonobo-activation-Registration.html#bonobo-activation-registration-env-free">bonobo_activation_registration_env_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">reg_env</span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
</p>
<p>
If <em class="parameter"><code>reg_env</code></em> is <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the global registration environment
list will be used if it is set. See
<a class="link" href="bonobo-activation-Registration.html#bonobo-activation-registration-env-set-global" title="bonobo_activation_registration_env_set_global ()"><code class="function">bonobo_activation_registration_env_set_global()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>iid</code></em> :</span></p></td>
<td>IID of the server to register.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>obj</code></em> :</span></p></td>
<td>CORBA::Object to register.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>reg_env</code></em> :</span></p></td>
<td>the registration environment.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> status of the registration.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="bonobo-activation-iid-get"></a><h3>bonobo_activation_iid_get ()</h3>
<pre class="programlisting">const <span class="returnvalue">char</span> *        bonobo_activation_iid_get           (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="BonoboActivationPlugin"></a><h3>BonoboActivationPlugin</h3>
<pre class="programlisting">typedef struct {
	const BonoboActivationPluginObject *plugin_object_list;
	const char *description;
        gpointer dummy[8];
} BonoboActivationPlugin;
</pre>
<p>
Components which want to be activated as
shared libraries must export an BonoboActivationPlugin
structure of name <span class="structname">Bonobo_Plugin_info</span>.
An exmaple of how to use it folows:
</p>
<pre class="programlisting">
static CORBA_Object
hi_shlib_make_object (PortableServer_POA poa,
                      const char *iid,
                      gpointer impl_ptr,
                      CORBA_Environment *ev)
{
        CORBA_Object object_ref;
        object_ref = impl_Hi__create (poa, ev);
        if (object_ref == CORBA_OBJECT_NIL
            || ev-&gt;_major != CORBA_NO_EXCEPTION) {
                printf ("Server cannot get objref\n");
                return CORBA_OBJECT_NIL;
        }
        bonobo_activation_plugin_use (poa, impl_ptr);
        return object_ref;
}
static const BonoboActivationPluginObject hi_plugin_list[] = {
        {
                "OAFIID:Hi:20000923",
                hi_shlib_make_object
        },
        {
                NULL
  	}
};
const BonoboActivationPlugin Bonobo_Plugin_info = {
        hi_plugin_list,
        "Hi example"
};
</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2">
<a name="BonoboActivationPluginObject"></a><h3>BonoboActivationPluginObject</h3>
<pre class="programlisting">typedef struct {
	const char *iid;

	/* This routine should call bonobo_activation_plugin_use(servant, impl_ptr), 
         * as should all routines which activate CORBA objects
	 * implemented by this shared library. This needs to be done 
         * before making any CORBA calls on the object, or
	 * passing that object around. First thing after servant creation 
         * always works. :) 
         */

        CORBA_Object (*activate) (PortableServer_POA poa,
                                  const char *iid, 
                                  gpointer impl_ptr, /* This pointer should be stored by the implementation
                                                         * to be passed to bonobo_activation_plugin_unuse() in the 
                                                         * implementation's destruction routine. */
				  CORBA_Environment *ev);
        gpointer dummy[4];
} BonoboActivationPluginObject;
</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2">
<a name="bonobo-activation-plugin-use"></a><h3>bonobo_activation_plugin_use ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                bonobo_activation_plugin_use        (<em class="parameter"><code><span class="type">PortableServer_Servant</span> servant</code></em>,
                                                         <em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> impl_ptr</code></em>);</pre>
<p>
You should call this routine to activate a shared library-based 
CORBA Object. It will be called by OAF if the component exports 
correctly an <a class="link" href="bonobo-activation-Registration.html#BonoboActivationPlugin" title="BonoboActivationPlugin"><code class="literal">BonoboActivationPlugin</code></a> structure named "Bonobo_Plugin_info".
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>servant</code></em> :</span></p></td>
<td>The servant that was created
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>impl_ptr</code></em> :</span></p></td>
<td>The impl_ptr that was passed to the original activation routine
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="bonobo-activation-plugin-unuse"></a><h3>bonobo_activation_plugin_unuse ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                bonobo_activation_plugin_unuse      (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> impl_ptr</code></em>);</pre>
<p>
Side effects: May arrange for the shared library that the
implementation is in to be unloaded.
</p>
<p>
When a shlib plugin for a CORBA object is destroying an
implementation, it should call this function to make sure that the
shared library is unloaded as needed.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>impl_ptr</code></em> :</span></p></td>
<td>The impl_ptr that was passed to the activation routine
</td>
</tr></tbody>
</table></div>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.15.1</div>
</body>
</html>